package cn.cs.controller;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class KafkaController {
    //@Autowired
    @Resource
    private org.springframework.kafka.core.KafkaTemplate<String, String> KafkaTemplate;
    @RequestMapping(value = "/sendMsgToKafka")
    public String sendMsgToKafka() {
        for (int i = 0; i < 10; i++) {
            KafkaTemplate.send("item_consumer", "cs", "hello,Kafka!--->" + i);
        }
        return "发送消息到Kafka完毕";
    }

}
